<template>
  <div>
    <danger-detail-info :form="form"></danger-detail-info>
    <div class="block-box mt-10" v-if="form.Status==50">
      <div class="block-box_item">
          <div class="block-box_title">整改操作</div>
          <eagle-input
            name="uploader"
            label="整改图片"
            required
          >
            <template #input>
              <eagle-image-uploader :images.sync="editForm.CorrectiveAttachs"></eagle-image-uploader>
            </template>
          </eagle-input>
          <eagle-input
            v-model="editForm.CorrectiveDesc"
            rows="3"
            required
            autosize
            label="整改说明"
            type="textarea"
            placeholder="请输入整改说明"
            isInputText
          ></eagle-input>
      </div>
      <div class="btns mt-10 mb-10">
        <eagle-button class="submit-only" @click="submit">提交</eagle-button>
      </div>
    </div>
  </div>
</template>

<script>
import { deepClone } from "@/utils";
import DangerDetailInfo from './dangerDetailInfo.vue';

export default {
  components: { DangerDetailInfo },
  data() {
    return {
      baseUrl: process.env.VUE_APP_BASE_API,
      id: this.$route.query.id,
      form: {},
      editForm: {},
      images:[]
    };
  },
  created() {
    this.geDetail();
  },
  methods: {
    geDetail() {
      this.$axios.get("/DangerCheckTaskDetail/GetDetail",{params:{ id: this.id }}).then((res)=>{
        this.form = res.data;
        this.editForm = deepClone(res.data);
      })
    },
    onConfirm(date) {
      const dateTime = formatDate(date);
      this.editForm[this.idx] = getDate(dateTime);
      this.showCalendar = false;
    },
    submit() {
      let param = {
        ID: this.editForm.ID,
        CorrectiveDesc: this.editForm.CorrectiveDesc,
        CorrectiveAttachs: this.editForm.CorrectiveAttachs,
      };
      if(!param.CorrectiveAttachs){
        this.$toast("请选择整改图片");
          return false;
      }
      if(!param.CorrectiveDesc){
        this.$toast("请输入整改说明");
          return false;
      }
      this.$axios
      .post("/DangerCheckTaskDetail/ConfirmCorrective",param)
      .then((res)=>{
        this.$toast("提交成功");
        this.$router.goRefresh(-1);
      })
      .catch((err) => {
        console.log("err", err);
      });
    },
  },
};
</script>
